home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
code
/
p_serlib.sit
/
Serial Library Source Code
/
serial.setBuffer.dll.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-27
|
2KB
|
88 lines
/***********************************************************************/
/*
/* serial.setBuffer.dll.c
/* by Atul Butte
/* Copyright ⌐ 1989 by Microsoft Corporation
/* All Rights Reserved
/*
/* version 1.0
/*
/*
/* This CALL/REGISTER creates and returns an input buffer of the size given.
/*
/* Excel usage:
/*
/* = Register( "serial library", "serial.setBuffer", "JHH" )
/* = Call( ref, portNumber, size )
/*
/* where
/* portNumber = number of port (1 = modem, 2 = printer)
/* size = size of buffer to allocate
/*
/***********************************************************************/
/***********************************************************************/
/*
/* D E F I N E S
/*
/***********************************************************************/
#define ROUTINE_NAME "serial.setBuffer"
#define hNIL 0L
#define pNIL 0L
/***********************************************************************/
/*
/* I N C L U D E S
/*
/***********************************************************************/
#include "serial.h"
#include "error.h"
#include "get_port.h"
/***********************************************************************/
/*
/* main
/*
/***********************************************************************/
pascal unsigned long main( port, cch )
unsigned short port; /* serial port to use */
unsigned short cch; /* size of buffer to allocate */
{
register OSErr err; /* result code from Toolbox routines */
short refIn; /* reference number for input port */
short refOut; /* reference number for output port */
Ptr pch; /* pointer to the new buffer */
RememberA0();
SetUpA4();
err = get_port( port, &refIn, &refOut );
if( err != noErr ) {
display_error( "Illegal port number." );
RestoreA4( );
return( err );
}
pch = NewPtr( (long) cch );
if( pch == pNIL ) {
display_error( "Out of memory error." );
RestoreA4( );
return( 0 );
}
err = SerSetBuf( refIn, pch, cch );
if( err != noErr ) {
display_error( "Error in setting buffer." );
RestoreA4( );
return( 0 );
}
RestoreA4( );
return( (unsigned long) pch );
}
#include "get_port.c"